package com.situ.mall.product;

public class Singleton {
	//在类的内部去维护唯一的这个实例
	private static Singleton instance;
	
	//回收new对象控制权，private只能在类的内部使用
	private Singleton(){
	
	}
	
	//单例模式里面返回唯一实例方法
	public static Singleton getInstance(){
		if(instance == null){
			synchronized (Singleton.class){
				if(instance == null){  //双重检查机制
					instance = new Singleton();
				}
			}
		}
		return instance;
	}
}
